package com.linked.store.label.service.impl;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.linked.store.label.bean.param.AddLabelInfoParam;
import com.linked.store.label.bean.param.PasteLabelParam;
import com.linked.store.label.bean.po.LabelBelongPO;
import com.linked.store.label.bean.po.LabelInfoPO;
import com.linked.store.label.mapper.ILabelBelongMapper;
import com.linked.store.label.mapper.ILabelInfoMapper;
import com.linked.store.label.service.ILabelHandleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :dbq
 * @date : 2023/3/23 15:12
 * @description : desc
 */
@Slf4j
@Service
public class LabelHandleServiceImpl implements ILabelHandleService {

    private final ObjectMapper mapper;

    private final ILabelInfoMapper labelInfoMapper;

    private final ILabelBelongMapper labelBelongMapper;

    @Autowired
    public LabelHandleServiceImpl(ObjectMapper mapper, ILabelInfoMapper labelInfoMapper, ILabelBelongMapper labelBelongMapper) {
        this.mapper = mapper;
        this.labelInfoMapper = labelInfoMapper;
        this.labelBelongMapper = labelBelongMapper;
    }

    @Override
    public boolean addLabelInfo(AddLabelInfoParam param) throws Exception {
        LabelInfoPO temp = new LabelInfoPO(param);
        return labelInfoMapper.insert(temp) > 0;
    }

    @Override
    public boolean pasteLabel(PasteLabelParam param) throws Exception {
        LabelBelongPO temp = new LabelBelongPO(param);
        return labelBelongMapper.insert(temp) > 0;
    }
}
